from typing import List


class Solution:
    def maxWeight(self, pizzas: List[int]) -> int:
        pizzas.sort(reverse=True)
        n = len(pizzas)
        times = n // 4
        odd = (times + 1) // 2
        even = times // 2
        ans = sum(pizzas[:odd])
        ans += sum(pizzas[odd + 1 : 1 + odd + even * 2, 2])
        return ans
